package com.dapeis.core.spring.listener.jpush;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import cn.jpush.api.push.model.PushPayload;

import com.ag.module.common.plugin.jpush.JPushApi;

@Component
public class JPushEventListener implements ApplicationListener<JPushEvent> {
    final Logger logger = LoggerFactory.getLogger(getClass());

    @Async
    @Override
    public void onApplicationEvent(final JPushEvent event) {
	PushPayload pushPayload = (PushPayload) event.getSource();

	logger.info("jPush 推送信息:" + pushPayload.toJSON());
	JPushApi.push(pushPayload, event.getjPushConfig());
    }
}
